clear
clc

max_v=1.2;
min_v=0.3;
max_dist=10;
min_dist=0.5;
max_sig=pi/2;
min_sig=-pi/2;

R_min=0.13;

sio_crash=2;
sio_max=4;
min_sio=min_sig;
max_sio=max_sig;

k=(max_v-min_v)/(max_dist-min_dist);
b=min_v-k*min_dist;

dist_rand=max_dist*rand(30,1);
dist_range=[dist_rand;0;max_dist];
%sig_rand=min_sig+(max_sig-min_sig)*rand(30,1);
%正角度
% sig_rand=0+(max_sig-0)*rand(30,1);
%负角度
sig_rand=min_sig+(0-min_sig)*rand(30,1);
%正最大角
% sig_range=[sig_rand;0;max_sig];
%负最大角
sig_range=[sig_rand;0;min_sig];


sio_rand=sio_crash+(sio_max-sio_crash)*rand(30,1);
sio_range=[sio_rand;sio_max;sio_crash];
%正最大角
% dsio_rand=0+(max_sio-0)*rand(30,1);
% dsio_range=[dsio_rand;0;max_sio];
%负最大角
dsio_rand=min_sio+(0-min_sio)*rand(30,1);
dsio_range=[dsio_rand;0;min_sio];

v_range=[];
w_range=[];
number=size(dist_range);
for i=1:number(1)
    di=dist_range(i);
    sigi=sig_range(i);
    vi=k*di+b;
    %
    if(di>min_dist)
        if(sigi~=0)
            if(sigi>0)
                Ri=(di/2)/(cos(pi/2-sigi));
            else
                Ri=-(di/2)/(cos(-pi/2-sigi));
            end
            if(abs(Ri)<R_min)
                if(Ri<0)
                    Ri=-R_min;
                else
                    Ri=R_min;
                end
            end
            %
            wi=vi/Ri;
        else
            wi=0;
        end
        if(vi>max_v)
            vi=max_v;
        elseif(vi<min_v)
            vi=min_v;
        end
    else
        vi=0;
        wi=0;
    end
    v_range=[v_range;vi];
    w_range=[w_range;wi];
end